package com.example.tnot.Teacher.CoursePart.CourseInternal.ClassDetail.VpFragment.CheckProgress.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.CoursePart.CourseInternal.ClassDetail.VpFragment.CheckProgress.ItemBean.Progress;

import java.util.List;

public class CheckProgressAdapter extends RecyclerView.Adapter<CheckProgressAdapter.ViewHolder>{
    private List<Progress> list;
    public CheckProgressAdapter(List<Progress> list){
        this.list = list;
    }
    @NonNull
    @Override
    public CheckProgressAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_chapter_detail_check_progress, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CheckProgressAdapter.ViewHolder holder, int position) {
        //获取用户头像
//        holder.iv_avatar.setImageResource(list.get(position).getAvatar());
        holder.tv_completion.setText(list.get(position).getCompletion());
        holder.tv_student_name.setText(list.get(position).getName());
        holder.tv_student_id.setText(list.get(position).getStuId());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv_avatar;
        TextView tv_student_name,tv_student_id,tv_completion;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_avatar = itemView.findViewById(R.id.iv_avatar);
            tv_student_name = itemView.findViewById(R.id.tv_student_name);
            tv_student_id = itemView.findViewById(R.id.tv_student_id);
            tv_completion = itemView.findViewById(R.id.tv_completion);
        }
    }
}
